package com.rerun.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.rerun.entity.CollectionJob;
import com.rerun.entity.vo.JobDetailVo;
import com.rerun.mapper.CollectionJobMapper;
import com.rerun.service.ICollectionJobService;
import com.rerun.service.IJobService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author dax.
 * @version v1.0
 * @since 2017/10/26 9:33
 */
@Service
public class CollectionJobServiceImpl extends ServiceImpl<CollectionJobMapper,CollectionJob> implements ICollectionJobService {
   @Resource
   private CollectionJobMapper collectionJobMapper;
   @Resource
   private IJobService iJobService;
    @Override
    public CollectionJob selectByJobId(String jobId,String memberId) {
        return collectionJobMapper.selectByJobId(jobId,memberId);
    }

    @Override
    public Page<JobDetailVo> findPageByMemberId(Page<JobDetailVo> page, String memberId) {
      List<String> jobIds =collectionJobMapper.findPageByMemberId(page,memberId);
            if (CollectionUtils.isNotEmpty(jobIds)){
                List<JobDetailVo> detailVos= iJobService.jobDetails(jobIds);
                page.setRecords(detailVos);
            }
        return page;
    }
}
